<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>look</title>
    <link rel="stylesheet" href="../static/css/look.css">
</head>
<body>
<!-- 2.准备具有大小的DOM容器 -->
<div class="box"></div>
<br>
<p id='p'></p>
<p id='pp'></p>
<p id='a'></p>
<p id='b'></p>
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script src="../static/js/echarts.min.js"></script>
<script>
    var myChart = echarts.init(document.querySelector(".box"));

    myChart.setOption({
        title: {
            text: 'true_text'
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'shadow'
            }
        },
        legend: {},
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: {
            type: 'value',
            boundaryGap: [0, 0.01]
        },
        yAxis: {
            type: 'category',
            data: a
        },
        series: [

            {
                name: '字数',
                type: 'bar',
                data: b
            }
        ]
    });


    var option = myChart.getOption();
    $(document).ready(function () {
        $.ajax({
            type: "POST",
            url: "/look",
            success: function (message) {
                test = message
                data = message.username
                data_02 = message.score
                te = []
                for (var i in data) {
                    te.push(data[i])
                }
                console.log(message)
                console.log('aaa')
                de = []
                for (var i in data_02) {
                    de.push(data_02[i])
                }
                option.xAxis[0].data = te;
                option.series[0].data = de;
                myChart.setOption(option);
            },
            error: function () {
                console.log('sb');
            }
        });
    });


</script>
</body>
</html>
